{extend name="sitehome@style/base"/}
{block name="resources"}
<link rel="stylesheet" href="ADDON_NC_FILE_CSS/file.css">
{/block}
{block name="main"}
<div class="search-wrap layui-form nc-function-search">
	<div class="upload-wrap">
		<div>
			<button class="layui-btn layui-btn-sm"  onclick="upload($('.active .category-id').val())">上传图片</button>
		</div>
		{:hook("fileUpload", ["name" => "", 'type' => 'multiple', 'file_type' => 'IMAGE','size' => '2000', 'thumb_type' => 'big,mid,small' ], '', true)}
	</div>
	
	<div class="layui-form-item file-name-wrap">
		<div class="layui-input-inline">
			<input type="text" name="search_file_name" required="" lay-verify="file_name" placeholder="请输入图片名称" autocomplete="off" class="layui-input">
		</div>
		<button class="layui-btn" lay-submit lay-filter="search">搜索</button>
	</div>
	<div class="layui-form-item file-order">
		<label class="layui-form-label">排序</label>
		<div class="layui-input-inline nc-len-short">
			<select id="img_order">
				<option value="create_time desc">创建时间↑</option>
				<option value="create_time asc">创建时间↓</option>
				<option value="file_name desc">图片名称↑</option>
				<option value="file_name asc">图片名称↓</option>
				<option value="size desc">图片大小↑</option>
				<option value="size asc">图片大小↓</option>
			</select>
		</div>
	</div>
</div>

<div class="category-list">
	<div id="t_category">
		{foreach name="$category_list" item="vo" key="k"}
		<div class="category-item {if $k==0}active{/if}">
			<span class="category-name">{$vo.name}</span>
			<span class="category-num">{$vo.num}</span>
			<input type="hidden" value="{$vo.id}" class="category-id">
			<input type="hidden" value="{$vo.is_default}" name="is_default">
		</div>
		{/foreach}
	</div>
	<div class="category-menu">
		<button class="layui-btn layui-btn-sm add-group">添加分组</button>
	</div>
</div>

<script id="category" type="text/html">
	
	{{#  layui.each(d, function(index, item){ }}
	{{# if(d.category_id > 0){ }}
	{{#  if(item['id'] == d.category_id){ }}
	<div class="category-item active">
		{{# } else { }}
		<div class="category-item">
			{{#  } }}
			{{# } else { }}
			{{# if(index == 0){ }}
			<div class="category-item active">
				{{# } else { }}
				<div class="category-item">
					{{#  } }}
					{{#  } }}
					<span class="category-name">{{ item['name'] }}</span>
					<span class="category-num">{{ item['num'] }}</span>
					<input type="hidden" value="{{ item['id'] }}" class="category-id" />
					<input type="hidden" value="{{ item['is_default'] }}" name="is_default">
				</div>
				
				{{#  }); }}
</script>

<div class="attachment-container">
	<div class="layui-form">
		<div class="layui-form-item">
			<span class="group_name">默认分组</span>
			<span id="operation"> 
				<span class="rename nc-text-color">重命名 </span>
				<span class="delete_packet">删除分组</span>
			</span>
		</div>
	</div>
	
	<div class="layui-form action-bar">
		<div class="layui-form-item">
			<input type="checkbox" lay-skin="primary" title="全选" lay-filter="allChoose">
		</div>
	</div>
	
	<div>
		<div class="layui-row" id="t_customerInfo"></div>
		
		<div style="display:none" class="image-data">
			<button class="layui-btn layui-btn-primary layui-btn-sm grouping-all">修改分组</button>
			<button class="layui-btn layui-btn-primary layui-btn-sm delete-all">删除</button>
			<div id="paged" class="page" style="float: right"></div>
		</div>
	</div>

</div>

<!-- 复制 -->
<script type="text/html" id="copy_path_html">
	<div class="layui-form">
		<div class="layui-form-item" id="copy_path">
			<div class="layui-inline" style="padding:20px 10px;">
				<div class="layui-input-inline">
					<input class="layui-input " type="text" id="path_file"value="{{ d.path }}" readonly>
				</div>
				<button class="layui-btn layui-btn-primary" onclick="JScopy()">复制</button>
				<input type="text" id="hidden_image_path" value="" style="top: -1000px; position: absolute;">
			</div>
		</div>
	</div>

</script>

<!-- 修改分组 -->
<script type="text/html" id="group_html">
	<div id="modify_group" class="group-portal">
		<div class="layui-form">
			<div class="layui-form-item">
				<p>选择分组</p>
				{volist name="category_list" id="vo"}
				<div class="layui-input-inline">
					<input type="radio" name="group_id" value="{$vo.id}" title="{$vo.name}" lay-filter="example" {{#  if(d.category_id == {$vo.id} ){ }} checked {{#  } }}>
				</div>
				{/volist}
			</div>
		</div>
	</div>
</script>

<!-- 相册 -->
<script type="text/html" id="album_html" >
	
	{{#  layui.each(d.list, function(index, item){ }}
	<div class="layui-col-md2">
		<div class="image-box">
			<!--big_pic_path-->
			<img layer-pid="{{ item.id }}" layer-src="{{ nc.img(item.path) }}" src="{{ nc.img(item.path) }}" alt="{{ item.file_name }}"/>
		</div>
		<div class="image-title">
			<div class="layui-form" >
				<span class="layui-form-item">
					<input type="checkbox" name="check[]" lay-skin="primary" title="{{ item.file_name  }}" value="{{ item.id }}" lay-filter="oneChoose">
				</span>
			</div>
		</div>
		<div class="image-link">
			<div>
				<a href="javascript:;" class="file-rename">改名</a>
				<input type="hidden" value="{{ item.id }}" class="file_id"/>
				<input type="hidden" value="{{ item.file_name }}" class="file_name"/>
			</div>
			<span class="opts-seprate">|</span>
			<div>
				<a href="javascript:;" class="pathlink">链接</a>
				<input type="hidden" value=" {{ nc.img(item.path)  }}" class="file_path"/>
			</div>
			<span class="opts-seprate">|</span>
			<div>
				<a href="javascript:;" class="grouping">分组</a>
				<input type="hidden" value="{{ item.id }}" class="file_id"/>
			</div>
			<span class="opts-seprate">|</span>
			<div>
				<a href="javascript:;" class="delfile">删除</a>
				<input type="hidden" value="{{ item.id }}" class="file_id"/>
			</div>
		</div>
	</div>
	{{#  }); }}
	{{#  if(d.list.length === 0){ }}
	<br/><span style='width:10%;height:30px;display:block;margin:0 auto;'>暂无数据</span>
	{{#  } }}
</script>
{/block}
{block name="script"}

<script>
	/**
	 * 多图上传回调
	 */
	function singleMultipleImageUploadSuccess(data, name){
		getFileAlbumList(1, limit); //重新分组
	}
	
</script>

<script src="ADDON_NC_FILE_JS/image.js"></script>
{/block}